package com.liangzdemo.observer;

import java.util.*;
import com.liangzdemo.observer.Observer;
//import java.util.Observer;

/**
 * Created by liangz on 2018/3/25.
 */

public class LoginFunction implements Function {

    private List<Observer> observers = new ArrayList<>();
    private boolean isLogin;


    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObserver() {
        for(Observer observer : observers) {
            observer.upLoginTag(isLogin);
        }
    }

    public void setLoginTag(boolean isLogin) {
        this.isLogin = isLogin;
        notifyObserver();
    }
}
